package org.example;

import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.stream.Stream;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-06-03
 * Time:16:21
 * Text：
 */
@TestMethodOrder(MethodOrderer.class)
public class JunitTest {
    @Test
    @Order(1)
    void Test01(){
        System.out.println("这是JunitTest");
    }
    @Test
    void Test02(){
        System.out.println("这是JunitTest2");

    }
    @Test
    void Test03(){
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.baidu.com");
        driver.findElement(By.cssSelector("#id"));
    }
    @BeforeAll
    static void SetUp(){
        System.out.println("我第一个");
    }
    @AfterAll
    static  void TearDown(){
        System.out.println("我最后一个");
    }

    @ParameterizedTest
    @ValueSource(ints = {1,2,3})  //传入的参数
    void Test04(int num){
        System.out.println(num);
    }

    @ParameterizedTest
    @CsvFileSource(resources =  "test01.csv")
    void Test06(String name){
        System.out.println(name);
    }

    @ParameterizedTest
    @CsvSource({"1,2,3,,"})
    void Test08(String name,String x,int y,String z){
        System.out.println(name);
        System.out.println(x);
        System.out.println(y);
        System.out.println(z);

    }

    @ParameterizedTest
    @MethodSource("Generator")
    void Test07(int num,String name){
        System.out.println(num+" : "+name);
    }
    public static Stream<Arguments> Generator(){
        return Stream.of(Arguments.arguments(1,"张三"),
                Arguments.arguments(2,"李四"));
    }

}
